using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter11
{
	/// <summary>
	/// Example07: Formation of a Neutron Star
	/// A star rotates with a period of 30 days about 
	/// an axis through its center. After the star undergoes 
	/// a supernova explosion, the stellar core, which had a 
	/// radius of 1.0 \times 10^4 km, collapses into a neutron star 
	/// of radius 3.0 km. determine the period of rotation 
	/// of the neutron star.
	/// T_f = 0.23 sec
	/// </summary>
	public class Example07
	{
		public Example07()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.Mass m = new L.Mass();
			m.kg = 108.0;
			L.Length rBefore = new L.Length();
			rBefore.m = 10000000.0;
			L.Length rAfter = new L.Length();
			rAfter.m = 3000.0;
			L.RigidBody before = new L.RigidBody(m);
			before.SetSphere(rBefore);
			L.RigidBody after = new L.RigidBody(m);
			after.SetSphere(rAfter);

			L.AngularVelocity wi = new L.AngularVelocity();
			wi.Z = 2.0*Math.PI/(30.0*24.0*60.0*60.0);

			L.Time t = new L.Time();
			t.s = after.RigidBodyMomentOfInertia.ZZ
				/before.RigidBodyMomentOfInertia.ZZ
				/wi.Z*2.0*Math.PI;

			result += Convert.ToString(t.s);
		}
	}
}
